Add host dependency path via -L for cross compiles
authorAlex Crichton <alex@alexcrichton.com>
Mon, 28 Nov 2016 15:27:14 +0000 (07:27 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Fri, 2 Dec 2016 06:47:28 +0000 (22:47 -0800)
Now that proc-macro crates can reexport from their dependencies we need to be
able to find the other crates, so ensure that we pass an appropriate -L flag.

Closes #3334

src/cargo/ops/cargo_rustc/context.rs
src/cargo/ops/cargo_rustc/mod.rs
tests/cross-compile.rs

index c0a92d643ec4188f7976eb68d187d5737bf8fbf5..74ba9b600377c97b1a648e00e4ac7f08127c1768 100644 (file)
@@ -314,6 +314,10 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
         self.layout(unit.kind).build().join(dir).join("out")
     }
 
+    pub fn host_deps(&self) -> &Path {
+        self.host.deps()
+    }
+
     /// Returns the appropriate output directory for the specified package and
     /// target.
     pub fn out_dir(&mut self, unit: &Unit) -> PathBuf {
index 561949b71234d72ebb80d4161d4cbdb2dd30b909..e54f539f39279110f27fed3e3d54939817f4786f 100644 (file)
@@ -648,6 +648,16 @@ fn build_deps_args(cmd: &mut ProcessBuilder, cx: &mut Context, unit: &Unit)
         deps
     });
 
+    // Be sure that the host path is also listed. This'll ensure that proc-macro
+    // dependencies are correctly found (for reexported macros).
+    if let Kind::Target = unit.kind {
+        cmd.arg("-L").arg(&{
+            let mut deps = OsString::from("dependency=");
+            deps.push(cx.host_deps());
+            deps
+        });
+    }
+
     for unit in cx.dep_targets(unit)?.iter() {
         if unit.profile.run_custom_build {
             cmd.env("OUT_DIR", &cx.build_script_out_dir(unit));
index 6cffa301fb15914535c713577be4a9a983f0f37a..c8cdc4aa757dc0d7f4955a922ce9bcd9c8eab40b 100644 (file)
@@ -363,7 +363,8 @@ fn linker_and_ar() {
     --emit=dep-info,link \
     --target {target} \
     -C ar=my-ar-tool -C linker=my-linker-tool \
-    -L dependency={dir}[/]target[/]{target}[/]debug[/]deps`
+    -L dependency={dir}[/]target[/]{target}[/]debug[/]deps \
+    -L dependency={dir}[/]target[/]debug[/]deps`
 ",
                             dir = p.root().display(),
                             url = p.url(),